emulator: Add new hook functions for load/store privileged state.
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Thu, 25 Jan 2007 13:02:03 +0000 (13:02 +0000)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Thu, 25 Jan 2007 13:02:03 +0000 (13:02 +0000)
Signed-off-by: Keir Fraser <keir@xensource.com>
xen/arch/x86/x86_emulate.c
xen/include/asm-x86/x86_emulate.h

index 7788961f3612cb12819606beca8ac17c0b248866..5ee9e5ceed201df65483fe52d8d9b3ee1bf1caef 100644 (file)
@@ -4,6 +4,7 @@
  * Generic x86 (32-bit and 64-bit) instruction decoder and emulator.
  * 
  * Copyright (c) 2005-2007 Keir Fraser
+ * Copyright (c) 2005-2007 XenSource Inc.
  * 
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
index 45246b8044ac7064b3ea12dd284a98d14a6a7f9e..b38cc3f47184899ccc5e04c7856c548cc9ce64e3 100644 (file)
@@ -4,6 +4,7 @@
  * Generic x86 (32-bit and 64-bit) instruction decoder and emulator.
  * 
  * Copyright (c) 2005-2007 Keir Fraser
+ * Copyright (c) 2005-2007 XenSource Inc.
  * 
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -69,16 +70,19 @@ struct x86_emulate_ops
 {
     /*
      * All functions:
+     *  @ctxt:  [IN ] Emulation context info as passed to the emulator.
+     * All memory-access functions:
      *  @seg:   [IN ] Segment being dereferenced (specified as x86_seg_??).
      *  @offset:[IN ] Offset within segment.
-     *  @ctxt:  [IN ] Emulation context info as passed to the emulator.
+     * Read functions:
+     *  @val:   [OUT] Value read, zero-extended to 'ulong'.
+     * Write functions:
+     *  @val:   [IN ] Value to write (low-order bytes used as req'd).
+     * Variable-length access functions:
+     *  @bytes: [IN ] Number of bytes to read or write.
      */
 
-    /*
-     * read: Emulate a memory read.
-     *  @val:   [OUT] Value read from memory, zero-extended to 'ulong'.
-     *  @bytes: [IN ] Number of bytes to read from memory.
-     */
+    /* read: Emulate a memory read. */
     int (*read)(
         enum x86_segment seg,
         unsigned long offset,
@@ -97,11 +101,7 @@ struct x86_emulate_ops
         unsigned int bytes,
         struct x86_emulate_ctxt *ctxt);
 
-    /*
-     * write: Emulate a memory write.
-     *  @val:   [IN ] Value to write to memory (low-order bytes used as req'd).
-     *  @bytes: [IN ] Number of bytes to write to memory.
-     */
+    /* write: Emulate a memory write. */
     int (*write)(
         enum x86_segment seg,
         unsigned long offset,
@@ -113,7 +113,6 @@ struct x86_emulate_ops
      * cmpxchg: Emulate an atomic (LOCKed) CMPXCHG operation.
      *  @old:   [IN ] Value expected to be current at @addr.
      *  @new:   [IN ] Value to write to @addr.
-     *  @bytes: [IN ] Number of bytes to access using CMPXCHG.
      */
     int (*cmpxchg)(
         enum x86_segment seg,
@@ -141,6 +140,89 @@ struct x86_emulate_ops
         unsigned long new_lo,
         unsigned long new_hi,
         struct x86_emulate_ctxt *ctxt);
+
+    /*
+     * read_io: Read from I/O port(s).
+     *  @port:  [IN ] Base port for access.
+     */
+    int (*read_io)(
+        unsigned int port,
+        unsigned int bytes,
+        unsigned long *val,
+        struct x86_emulate_ctxt *ctxt);
+
+    /*
+     * write_io: Write to I/O port(s).
+     *  @port:  [IN ] Base port for access.
+     */
+    int (*write_io)(
+        unsigned int port,
+        unsigned int bytes,
+        unsigned long val,
+        struct x86_emulate_ctxt *ctxt);
+
+    /*
+     * read_cr: Read from control register.
+     *  @reg:   [IN ] Register to read (0-15).
+     */
+    int (*read_cr)(
+        unsigned int reg,
+        unsigned long *val,
+        struct x86_emulate_ctxt *ctxt);
+
+    /*
+     * write_cr: Write to control register.
+     *  @reg:   [IN ] Register to write (0-15).
+     */
+    int (*write_cr)(
+        unsigned int reg,
+        unsigned long val,
+        struct x86_emulate_ctxt *ctxt);
+
+    /*
+     * read_dr: Read from debug register.
+     *  @reg:   [IN ] Register to read (0-15).
+     */
+    int (*read_dr)(
+        unsigned int reg,
+        unsigned long *val,
+        struct x86_emulate_ctxt *ctxt);
+
+    /*
+     * write_dr: Write to debug register.
+     *  @reg:   [IN ] Register to write (0-15).
+     */
+    int (*write_dr)(
+        unsigned int reg,
+        unsigned long val,
+        struct x86_emulate_ctxt *ctxt);
+
+    /*
+     * read_msr: Read from model-specific register.
+     *  @reg:   [IN ] Register to read.
+     */
+    int (*read_msr)(
+        unsigned long reg,
+        uint64_t *val,
+        struct x86_emulate_ctxt *ctxt);
+
+    /*
+     * write_dr: Write to model-specific register.
+     *  @reg:   [IN ] Register to write.
+     */
+    int (*write_msr)(
+        unsigned long reg,
+        uint64_t val,
+        struct x86_emulate_ctxt *ctxt);
+
+    /* write_rflags: Modify privileged bits in RFLAGS. */
+    int (*write_rflags)(
+        unsigned long val,
+        struct x86_emulate_ctxt *ctxt);
+
+    /* wbinvd: Write-back and invalidate cache contents. */
+    int (*wbinvd)(
+        struct x86_emulate_ctxt *ctxt);
 };
 
 struct cpu_user_regs;